index.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. "use client";
  2. import { getWheelApi } from "@/api/cashWheel";
  3. import { useRouter } from "@/i18n/routing";
  4. import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
  5. import { Badge, Toast } from "antd-mobile";
  6. import { useTranslations } from "next-intl";
  7. import { FC } from "react";
  8. import "./style.scss";
  9. /**
  10. * @description 列表组件
  11. * @param {string} type 使用类型
  12. * @param {(params: any) => void} callbackFun 回调方法
  13. */
  14. export interface ItemComProps {
  15. type?: string;
  16. }
  17. const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
  18. const t = useTranslations("ProfilePage");
  19. const router = useRouter();
  20. const { unread, userUnread } = useGlobalNoticeStore((state) => ({
  21. unread: state.unread,
  22. userUnread: state.userUnred,
  23. }));
  24. const links = [
  25. { label: "gratis", desc: "gratisDesc", icon: "", url: "/", content: null },
  26. {
  27. label: "company",
  28. desc: "",
  29. icon: "icon-huo",
  30. color: "rgb(255, 147, 35)",
  31. url: "/affiliate/summary",
  32. content: null,
  33. },
  34. {
  35. label: "pray",
  36. desc: "",
  37. icon: "icon-mianfei",
  38. color: "#20894d",
  39. url: "/cashWheel",
  40. content: null,
  41. },
  42. {
  43. label: "cashback",
  44. desc: "",
  45. icon: "icon-qiandai",
  46. color: "rgb(255, 147, 35)",
  47. url: "/cashback",
  48. content: null,
  49. },
  50. { label: "gamblingBets", desc: "", icon: "", url: "/betrecord", content: null },
  51. { label: "league", desc: "", icon: "", url: "/", content: null },
  52. { label: "instant", desc: "", icon: "", url: "/", content: null },
  53. { label: "transactions", desc: "", icon: "", url: "/transactions", content: null },
  54. {
  55. label: "message",
  56. desc: "",
  57. icon: "",
  58. url: "/notification",
  59. content: unread || userUnread ? Badge.dot : null,
  60. },
  61. { label: "initial", desc: "", icon: "", url: "/", content: null },
  62. ];
  63. const routerHandler = (item: any) => {
  64. if (item.url === "/cashWheel") {
  65. getWheelApi().then((res) => {
  66. if (!Array.isArray(res.data) && !!res.data.activities) {
  67. router.push(item.url);
  68. } else {
  69. Toast.show("The event is not open");
  70. }
  71. });
  72. } else {
  73. router.push(item.url);
  74. }
  75. };
  76. return (
  77. <div className="itemCom-box">
  78. {links.map((item, index) => (
  79. <div
  80. className={`${index == 0 ? "free" : ""} box-item`}
  81. onClick={() => routerHandler(item)}
  82. key={index}
  83. >
  84. <div className={`${item.desc ? "box-item__left" : ""}`}>
  85. <Badge content={item.content}>
  86. <div className="content">
  87. {t(item.label)}
  88. <i
  89. className={`iconfont ${item.icon}`}
  90. style={{ color: item.color }}
  91. ></i>
  92. </div>
  93. {item.desc && <p className={"desc"}>{t(item.desc)}</p>}
  94. </Badge>
  95. </div>
  96. <div>
  97. <span className="iconfont icon-xiangyou1"></span>
  98. </div>
  99. </div>
  100. ))}
  101. </div>
  102. );
  103. };
  104. export default ItemCom;